Inline CSS
We can apply CSS to a single element using the inline CSS method.
Inline CSS is another method to add styles directly into an HTML
document. However, it reduces some of the benefits of using stylesheets,
so it is recommended to use this method sparingly.
If you choose to use inline CSS, apply the style attribute to the
relevant tag
We can apply CSS to a single element using the inline CSS method.
Inline CSS is another method to add styles directly into an HTML
document. However, it reduces some of the benefits of using stylesheets,
so it is recommended to use this method sparingly.
If you choose to use inline CSS, apply the style attribute to the
relevant tag
Syntax
<element style="property1: value; property2: value;"></element>
<element style="property1: value; property2: value;"></element>
Example
<h1>Heading</h1>
<p>paragraph</p>
Output
Disadvantages of Inline CSS
-
Quotation marks cannot be used within inline CSS; if you do, the
browser will treat them as the end of the style value.
-
These styles cannot be reused in other parts of the document.
-
These styles are difficult to edit because they aren't stored in a
single location.
-
You cannot use inline CSS to style pseudo-elements and
pseudo-classes.
-
Inline CSS does not offer the benefits of browser caching.
- Quotation marks cannot be used within inline CSS; if you do, the browser will treat them as the end of the style value.
- These styles cannot be reused in other parts of the document.
- These styles are difficult to edit because they aren't stored in a single location.
- You cannot use inline CSS to style pseudo-elements and pseudo-classes.
- Inline CSS does not offer the benefits of browser caching.